function CreateDiv(id,url,name){
    if($('.navtab').width()>=960){
        $('.deterBody').css('display','block');
        $('.tabError').addClass('transscale');
        $('.'+id+'').attr("href","javascript:void(0)");
        $('.btn-cancel').on('click',function(){
            $('.deterBody').css('display','none');
            $('.tabError').removeClass('transscale');
        })
        return false;
    }
    if(document.getElementById("div_" + id) == null){
        var newIframe="<iframe  id='div_"+id+"' name='"+id+"' src='"+url+"' width='100%' height='525'  frameborder='no' scrolling='yes'  allowTransparency='true'></iframe>";
        $('.content').append(newIframe);
        var $tas=$('.topbar ul li');
        var $conList=$('.content iframe');
        console.log($conList);
        if($tas.length>=1){
            $tas.each(function(index){
                $tas[index].className = "";
                $conList[index].style.display = "none";
            })
        }
        var ifh=document.getElementById('div_'+id);
        ifh.height=document.documentElement.clientHeight;
        var newLi='<li  id="'+id+'" class="active"><a target="'+id+'"  href="'+url+'">'+name+'<i class="fa fa-times-circle"></i></a></li>'
        $('.topbar ul').append(newLi);
    }else{
        var $tas=$('.topbar ul li');
        var $conList=$('.content  iframe');
        console.log($conList)
        $tas.each(function(index){
            $tas[index].className = "";
            $conList[index].style.display = "none";
        })
        $('#'+id+'').addClass('active');
        $('#div_'+id+'').css('display','block')
    }
}
function romoveCon(id){
    $('#'+id+'').children().remove();
    $('#'+id+'').parent().children('#'+id+'').remove();
    var $odiv=$('#div_'+id+'')
    $odiv.parent().children('#div_'+id+'').remove();
    var $tas=$('.navtab li a');
    var $lis=$('.navtab li');
    var $conList=$('.content  iframe');
    if ($tas.length > 0){
        $lis[$tas.length-1].className = "active";
        $conList[$tas.length-1].style.display = "block";
    }
};
function addClick(id,url,name){
    $('.'+id).on('click',function(){
        CreateDiv(id,url,name);
        $('#'+id).on('click',function(){
            CreateDiv(id,url,name);
        })
        $('#'+id+'  i').on('mousedown',function(){
            romoveCon(id)
        })
    })
};